﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 增加职业职称表 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "EducationType",
                table: "SysPersonEducation",
                type: "int",
                maxLength: 128,
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "ArchiveAgeDateFormat",
                table: "SysPerson",
                type: "datetime2",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "JoinWorkDate",
                table: "SysPerson",
                type: "datetime2",
                nullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Code",
                table: "SysJobPosition",
                type: "nvarchar(64)",
                maxLength: 64,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "nvarchar(64)",
                oldMaxLength: 64);

            migrationBuilder.CreateTable(
                name: "SysPersonProfessionalTitle",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PersonId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    TitleName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    TitleLevel = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    TitleDocumentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysPersonProfessionalTitle", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysPersonProfessionalTitle_FileAttachments_TitleDocumentId",
                        column: x => x.TitleDocumentId,
                        principalTable: "FileAttachments",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_SysPersonProfessionalTitle_SysPerson_PersonId",
                        column: x => x.PersonId,
                        principalTable: "SysPerson",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysPersonProfessionalTitle_PersonId",
                table: "SysPersonProfessionalTitle",
                column: "PersonId");

            migrationBuilder.CreateIndex(
                name: "IX_SysPersonProfessionalTitle_TitleDocumentId",
                table: "SysPersonProfessionalTitle",
                column: "TitleDocumentId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysPersonProfessionalTitle");

            migrationBuilder.DropColumn(
                name: "EducationType",
                table: "SysPersonEducation");

            migrationBuilder.DropColumn(
                name: "ArchiveAgeDateFormat",
                table: "SysPerson");

            migrationBuilder.DropColumn(
                name: "JoinWorkDate",
                table: "SysPerson");

            migrationBuilder.AlterColumn<string>(
                name: "Code",
                table: "SysJobPosition",
                type: "nvarchar(64)",
                maxLength: 64,
                nullable: false,
                defaultValue: "",
                oldClrType: typeof(string),
                oldType: "nvarchar(64)",
                oldMaxLength: 64,
                oldNullable: true);
        }
    }
}
